#ifndef SK_GAME_MODEL_H
#define SK_GAME_MODEL_H

#include <QAbstractItemModel>
#include <QModelIndex>
#include <QVector>

namespace sk
{
    class GameItem;

    class GameModel : public QAbstractItemModel
    {
    public:
        GameModel(QObject * parent);
        ~GameModel();

        virtual QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
        virtual QModelIndex parent(const QModelIndex &child) const;
        int rowCount(const QModelIndex &parent = QModelIndex()) const;
        int columnCount(const QModelIndex &parent = QModelIndex()) const;
        virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;

        GameItem * getItem(const QModelIndex &index) const;
        void reload(GameItem * rootItem);
        
        void onSwapItems(GameItem * parent, int i, int j);
        
		GameItem * create(GameItem * parent, void * param);
        void remove(GameItem * item);        

        QModelIndex getParentIndex(const QVector<int>& _index);
        QModelIndex getIndex(const QVector<int>& _index);
        QModelIndex getIndex(GameItem * item);

    private:
        sk::GameItem * _rootItem;
    };

} // namespace sk

#endif // SK_GAME_MODEL_H
